﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sy4_10
{
    public partial class Form2 : Form
    {
        ListBox lbx2;
        public Form2(ListBox lbx)
        {
            InitializeComponent();
            lbx2 = lbx;
        }

        private void Form2_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (timer1.Enabled == false)
            {
                timer1.Enabled = true;
                button1.Text = "结束抽奖";
            }
            else
            {
                timer1.Enabled = false;
                button1.Text = "开始抽奖";
            }
        }

        Random rnd = new Random();
        private void timer1_Tick(object sender, EventArgs e)
        {
            int n = rnd.Next(lbx2.Items.Count);
            label1.Text = lbx2.Items[n].ToString();
        }
    }
}
